<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="root">
    <h2>当前计数器:<span></span></h2>
    <button class="inc">+1</button>
    <button class="dec">-1</button>
  </div>
  <script>
   var counter=100;
   var span=document.querySelector("span")
   span.innerHTML=counter;
   var incBtn=document.querySelector(".inc");
   var decBtn=document.querySelector(".dec");
   incBtn.onclick=function(){
       counter++;
       span.innerHTML=counter;
   }
   decBtn.onclick=function(){
       counter--;
       span.innerHTML=counter;
   }
  </script>
</body>
</html>